package shiyan2;

public class Complex1_1 {
	double real,i;
	public Complex1_1(){
		this.real=0;
		this.i=0;
	}
public Complex1_1(double real,double i){
	this.real=real;
	this.i = i;
}
public double getreal(){
	return real;
}
public double geti(){
	return i;
	}
public void setReal(double real){
	this.real=real;
}
public void setI(double i){
	this.i=i;
}
public Complex1_1 jiaComplex1_1(Complex1_1 a,Complex1_1 b){
	Complex1_1 temp = new Complex1_1();
	temp.real=a.real+b.real;
    temp.i =a.i +b.i;
    return temp;
}

public Complex1_1 jianComplex1_1(Complex1_1 a,Complex1_1 b){
	Complex1_1 temp = new Complex1_1();
    temp.real = a.real-b.real;
    temp.i = a.i-b.i;
    return temp;
}
public void jiaComplex1_1(Complex1_1 ex){
	this.real=this.real+ex.real;
	this.i=this.i+ex.i;
}
public void jianComplex1_1(Complex1_1 ex){
	this.real = this.real- ex.real;
	this.i =this.i-ex.i;
}
public void printComplex1_1()        
{    if(this.i<0)
{    
System.out.println(""+this.real+"-"+this.i+"i");
}else if(this.i>0){
	System.out.println(""+this.real+"+"+this.i+"i");
}
}
public static void main(String[] args) 
{
	Complex1_1 q = new Complex1_1(5,2);
	   q.printComplex1_1();
       Complex1_1 w=new Complex1_1(0,5);
       w.printComplex1_1();
     Complex1_1 e = new Complex1_1(4,3);
      e.printComplex1_1();
      Complex1_1 r = new Complex1_1(0,4);
      r.printComplex1_1();
}
}

